﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true" CodeFile="key_dealer_play.aspx.cs" Inherits="key_dealer_play" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


     <div class="content">



        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

            <ContentTemplate>

                <div style="overflow:hidden;">
                    <br />
                </div>


                <div>

                     <asp:Label ID="lbl_status" runat="server" Text="บน" ClientIDMode="Static"></asp:Label>
        <asp:TextBox ID="txt_number" runat="server" onkeypress="return EnterEvent(event,'a1')" ClientIDMode="Static"></asp:TextBox>
        <asp:TextBox ID="txt_value" runat="server" onkeypress="return EnterEvent(event,'a2')" ClientIDMode="Static"></asp:TextBox>
                <asp:Label ID="lbl_subtotal" runat="server"></asp:Label>
        <asp:Button ID="btnsent" runat="server" Text="Sent" UseSubmitBehavior="False" ClientIDMode="Static" OnClick="btnsent_Click" />

                </div>





                <div>

       

                    <asp:DataList ID="DataList" runat="server" CellSpacing="3" OnItemDataBound="DataList_ItemDataBound" RepeatColumns="4">
                        <ItemTemplate>
                            <div class="keynumber">


<table>
    <tr>
        <td style="background-color: #000000; color:#fff;" width="30" align="center"><%# Container.ItemIndex + 1 %></td>
        <td width="50" align="center" ><%#Eval("key_number") %></td>
        <td><%#Eval("key_money") %></td>
        <td></td>
    </tr>
</table>





                            </div>
                        </ItemTemplate>
                    </asp:DataList>

                </div>



       
            </ContentTemplate>



        </asp:UpdatePanel>



    
    <script type="text/javascript">





        document.getElementById('txt_number').focus();
        
        function EnterEvent(e, type) {




            if (e.which == 13) {


                if (type == 'a1') { document.getElementById('txt_value').focus(); }
                if (type == 'a2') {
                    //document.getElementById('txt_money').focus();
           



                  var string_sprit = document.getElementById('txt_value').value;
                  var arr_spit = string_sprit.split("*");
                  //arr_spit = [0, 0, 0];
                  arr_spit = string_sprit.split("*");


                  var plusnumber = 0;

                  for (var i = 0; i <= arr_spit.length - 1; i++) {

                      plusnumber = parseInt(plusnumber) + parseInt(arr_spit[i]);

                  }


                  //alert(plusnumber);

              

               // document.getElementById('btnsent').focus();

                    document.getElementById('btnsent').click();
            }


                // if (type == 'a3') {  }

        }


        if (e.which == 43) {
            // e.returnValue = false;


       if (type == 'a1') {

        if (document.getElementById('<%= lbl_status.ClientID%>').innerText == "บน") {
            document.getElementById('<%= lbl_status.ClientID%>').innerText = 'ล่าง';

        }
        else if (document.getElementById('<%= lbl_status.ClientID%>').innerText == "ล่าง") {
            document.getElementById('<%= lbl_status.ClientID%>').innerText = 'บน+ล่าง';
        }
        else if (document.getElementById('<%= lbl_status.ClientID%>').innerText == "บน+ล่าง") {
            document.getElementById('<%= lbl_status.ClientID%>').innerText = 'บน';
        }


}


}




}







function pressPlus(o) {
    var k = event.keyCode
    if (k == 107) {
        o.value = lefty(o.value, parseInt(o.value.length) - 1)
    }
}




function lefty(instring, num) {
    var outstr = instring.substring(instring, num);
    return (outstr);
}








        </script>


        


    </div>




</asp:Content>

